/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uk.ac.cam.can.algorithm;


/**
 *
 * @author Thomas
 */
public class TCloseness /*extends KAnonimity*/{
    /*private double t;
    private Map result = null;
    private List<String> elements = new ArrayList<String>();
    
    public TCloseness(Map attributes, String fileName, String separator, int k, double t){
        super(attributes, fileName, separator, k);
        this.t=t;
        this.outFile="t-close_"+fileName;        
    }*/
    /*
    @Override
    protected boolean criteria(DataSet d, QGroup q){
        if(q.getK() < k)
            return false;
        else{
            boolean res = true;
            // we need to compute the probability distribution
            if(result==null){
                result = new HashMap();
                List<Record> records = d.getRecords();
                for(Record r : records){
                    String sa = "";
                    for(Attribute a : (Collection<Attribute>)attributes.values()){
                        if(a.getType()==Attribute.TYPE_SENSITIVE){
                            try{
                                sa += r.getAttribute(a.getPosition());
                            }catch(Exception e){
                                System.out.println(r);
                            }
                        }
                    }
                    if(result.containsKey(sa)){
                        int n= (Integer)result.get(sa);
                        n++;
                        result.put(sa, n);
                    }else{
                        elements.add(sa);
                        result.put(sa, 1);
                    }
                }
            }
            
            Map tmp = new HashMap();
            List<Record> records = q.getRecords();
            for(Record r : records){                
                String sa = "";
                for(Attribute a : (Collection<Attribute>)attributes.values()){
                    if(a.getType()==Attribute.TYPE_SENSITIVE){
                        sa += r.getAttribute(a.getPosition());
                    }
                }
                if(tmp.containsKey(sa)){
                    int n = (Integer)tmp.get(sa);
                    n++;
                    tmp.put(sa, n);
                }else{                    
                    tmp.put(sa, 1);
                }
            }
            
            
            for(String e : elements){
                double pi = (double)((Integer)result.get(e)) / (double)d.getRecords().size();
                double qi = 0.0;
                if(tmp.containsKey(e))
                    qi = (double)((Integer)tmp.get(e)) / (double)records.size();
                
                if(Math.abs(pi-qi)<t)
                    res&=true;
                else{                   
                    res&=false;
                }
            }
            return res;
        }
    }*/
}
